package com.sweet.utils;

import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.util.MultiValueMap;
import org.springframework.web.util.UriComponentsBuilder;

import java.util.Arrays;

public class HeadUtils {

    public static HttpHeaders templateHeader() {
        HttpHeaders headers = new HttpHeaders();
        headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
        headers.setContentType(MediaType.APPLICATION_JSON);
        return headers;
    }

    public static HttpEntity<String> templateHttpEntity() {
        HttpHeaders headers = templateHeader();
        return new HttpEntity<>(headers);
    }

    public static String getCompleteUrl(String url, MultiValueMap<String, String> map) {
        UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url).queryParams(map);
        return builder.toUriString();
    }
}
